/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ultrasoft.farmasoft.domain;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Administrador
 */
@Entity
@Table(name = "defaultaccessprovider")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Defaultaccessprovider.findAll", query = "SELECT d FROM Defaultaccessprovider d"),
    @NamedQuery(name = "Defaultaccessprovider.findByRolProviderId", query = "SELECT d FROM Defaultaccessprovider d WHERE d.defaultaccessproviderPK.rolProviderId = :rolProviderId"),
    @NamedQuery(name = "Defaultaccessprovider.findByMenuProviderId", query = "SELECT d FROM Defaultaccessprovider d WHERE d.defaultaccessproviderPK.menuProviderId = :menuProviderId"),
    @NamedQuery(name = "Defaultaccessprovider.findBySubmenuProviderId", query = "SELECT d FROM Defaultaccessprovider d WHERE d.defaultaccessproviderPK.submenuProviderId = :submenuProviderId"),
    @NamedQuery(name = "Defaultaccessprovider.findByOptionProviderId", query = "SELECT d FROM Defaultaccessprovider d WHERE d.defaultaccessproviderPK.optionProviderId = :optionProviderId")})
public class Defaultaccessprovider implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected DefaultaccessproviderPK defaultaccessproviderPK;
    
    @JoinColumn(name = "rolProviderId", referencedColumnName = "rolProviderId", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Rolprovider rolprovider;
    @JoinColumns({
        @JoinColumn(name = "menuProviderId", referencedColumnName = "menuProviderId", insertable = false, updatable = false),
        @JoinColumn(name = "submenuProviderId", referencedColumnName = "submenuProviderId", insertable = false, updatable = false),
        @JoinColumn(name = "optionProviderId", referencedColumnName = "optionProviderId", insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private Optionprovider optionprovider;

    public Defaultaccessprovider() {
    }

    public Defaultaccessprovider(DefaultaccessproviderPK defaultaccessproviderPK) {
        this.defaultaccessproviderPK = defaultaccessproviderPK;
    }

    public Defaultaccessprovider(int rolProviderId, short menuProviderId, short submenuProviderId, short optionProviderId) {
        this.defaultaccessproviderPK = new DefaultaccessproviderPK(rolProviderId, menuProviderId, submenuProviderId, optionProviderId);
    }

    public DefaultaccessproviderPK getDefaultaccessproviderPK() {
        return defaultaccessproviderPK;
    }

    public void setDefaultaccessproviderPK(DefaultaccessproviderPK defaultaccessproviderPK) {
        this.defaultaccessproviderPK = defaultaccessproviderPK;
    }

    public Rolprovider getRolprovider() {
        return rolprovider;
    }

    public void setRolprovider(Rolprovider rolprovider) {
        this.rolprovider = rolprovider;
    }

    public Optionprovider getOptionprovider() {
        return optionprovider;
    }

    public void setOptionprovider(Optionprovider optionprovider) {
        this.optionprovider = optionprovider;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (defaultaccessproviderPK != null ? defaultaccessproviderPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Defaultaccessprovider)) {
            return false;
        }
        Defaultaccessprovider other = (Defaultaccessprovider) object;
        if ((this.defaultaccessproviderPK == null && other.defaultaccessproviderPK != null) || (this.defaultaccessproviderPK != null && !this.defaultaccessproviderPK.equals(other.defaultaccessproviderPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ultrasoft.farmasoft.domain.Defaultaccessprovider[ defaultaccessproviderPK=" + defaultaccessproviderPK + " ]";
    }
    
}
